package dataImport.model;

import dataImport.model.abstracts.AbstractEntity;


public class PredefinedAction extends AbstractEntity {

	private static final long serialVersionUID = 3172513228608209405L;

	private CustomAction customAction;

	private int position;

	private StaticAction staticAction;

	private AbstractEntity abstractEntity;
	
	public PredefinedAction(final CustomAction customAction, final int position, final StaticAction staticAction) {
		super(createId(customAction.getId(), staticAction.getName()));
		this.customAction = customAction;
		this.position = position;
		this.staticAction = staticAction;
		this.abstractEntity = null;
	}

	public PredefinedAction(final CustomAction customAction, final int position, final StaticAction staticAction, final AbstractEntity abstractEntity) {
		super(createId(customAction.getId(), staticAction.getName(), abstractEntity.getId()));
		this.customAction = customAction;
		this.position = position;
		this.staticAction = staticAction;
		this.abstractEntity = abstractEntity;
	}

	public CustomAction getCustomAction() {
		return this.customAction;
	}

	public void setCustomAction(CustomAction customAction) {
		this.customAction = customAction;
	}

	public int getPosition() {
		return this.position;
	}

	public void setPosition(int position) {
		this.position = position;
	}

	public StaticAction getStaticAction() {
		return this.staticAction;
	}

	public void setStaticAction(StaticAction staticAction) {
		this.staticAction = staticAction;
	}

	public AbstractEntity getAbstractEntity() {
		return this.abstractEntity;
	}

	public void setAbstractEntity(AbstractEntity abstractEntity) {
		this.abstractEntity = abstractEntity;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((this.abstractEntity == null) ? 0 : this.abstractEntity.hashCode());
		result = prime * result + ((this.customAction == null) ? 0 : this.customAction.hashCode());
		result = prime * result + this.position;
		result = prime * result + ((this.staticAction == null) ? 0 : this.staticAction.hashCode());
		return result;
	}

	@Override
	public boolean equals(java.lang.Object obj) {
		if (this == obj) {
			return true;
		}
		if (!super.equals(obj)) {
			return false;
		}
		if (this.getClass() != obj.getClass()) {
			return false;
		}
		PredefinedAction other = (PredefinedAction) obj;
		if (this.abstractEntity == null) {
			if (other.abstractEntity != null) {
				return false;
			}
		}
		else if (!this.abstractEntity.equals(other.abstractEntity)) {
			return false;
		}
		if (this.customAction == null) {
			if (other.customAction != null) {
				return false;
			}
		}
		else if (!this.customAction.equals(other.customAction)) {
			return false;
		}
		if (this.position != other.position) {
			return false;
		}
		if (this.staticAction != other.staticAction) {
			return false;
		}
		return true;
	}
}
